home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / dviware / dvibook / libtex / conv.c < prev    next >
C/C++ Source or Header  |  1994-03-18  |  1KB  |  53 lines

  1. /*
  2.  * Copyright (c) 1987, 1989 University of Maryland
  3.  * Department of Computer Science.  All rights reserved.
  4.  * Permission to copy for any purpose is hereby granted
  5.  * so long as this copyright notice remains intact.
  6.  */
  7.  
  8. #ifndef lint
  9. static char rcsid[] = "$Header: /usr/src/local/tex/local/mctex/lib/RCS/conv.c,v 3.1 89/08/22 21:48:01 chris Exp $";
  10. #endif
  11.  
  12. /*
  13.  * Conversions.
  14.  */
  15.  
  16. #include "types.h"
  17. #include "conv.h"
  18.  
  19. double    DMagFactor();
  20.  
  21. Conv    Conversion;        /* the global conversion */
  22.  
  23. /*
  24.  * Set a conversion (possibly the global conversion).
  25.  */
  26. void
  27. CSetConversion(c, dpi, usermag, num, denom, dvimag)
  28.     register struct conversion *c;
  29.     int dpi, usermag;
  30.     i32 num, denom, dvimag;
  31. {
  32.     double ddpi = dpi;
  33.  
  34.     c->c_mag = DMagFactor((int) dvimag) * DMagFactor(usermag);
  35.     c->c_dpi = ddpi;
  36.  
  37.     /*
  38.      * The conversion facture is figured as follows:  there are exactly
  39.      * num/denom DVI units per decimicron, and 254000 decimicrons per
  40.      * inch, and dpi pixels per inch.  Then we have to adjust this by
  41.      * the stated magnification. 
  42.      */
  43.     c->c_fromsp = (num / 254000.0) * (ddpi / denom) * c->c_mag;
  44.  
  45.     /*
  46.      * c->c_tosp is 1/c->c_fromsp, but we will invert the expression
  47.      * above in the hopes of some extra accuracy.
  48.      *
  49.      * IS THIS ANY GOOD?  I NEED A NUMERICAL ANALYST!
  50.      */
  51.     c->c_tosp = (254000.0 / num) * (denom / ddpi) * (1.0 / c->c_mag);
  52. }
  53.